<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

defined('_JEXEC') or die;

jimport('joomla.application.component.view');

class CprojectViewCprojects extends JView {

    protected $items;
    protected $state;
    protected $pagination;

    function display($tpl = null) {
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');

        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }
        //Them toolbar

        $this->addToolbar();


        //Tieu de
        $this->setDocument();
        parent::display($tpl);
    }

    function addToolbar() {
        $state = $this->get('State');

        $canDo = CprojectHelper::getActions();
        JToolBarHelper::title('Cproject Manager');

        if ($canDo->get('core.create')) {
            JToolBarHelper::addNew('cproject.add');
        }
        if ($canDo->get('core.edit')) {
            JToolBarHelper::editList('cproject.edit');
        }
        if ($canDo->get('core.delete')) {
            JToolBarHelper::deleteList('', 'cprojects.delete');
        }


        JToolBarHelper::divider();
        JToolBarHelper::publish('cprojects.publish', 'JTOOLBAR_PUBLISH', true);
        JToolBarHelper::unpublish('cprojects.unpublish', 'JTOOLBAR_UNPUBLISH', true);

        if ($canDo->get('core.admin')) {
            JToolBarHelper::divider();
            JToolBarHelper::preferences('com_cproject');
        }
    }

    function setDocument() {
        $document = JFactory::getDocument();
        $document->setTitle(JText::_('Cproject Manager'));
    }

}

?>
